<?php
/**
 *
 * (model)
 */
namespace App\Models\AmazonAds;

use App\Models\Basics\SysCountry;
use Illuminate\Database\Eloquent\Model;
class AdsError extends Model
{
    protected $table = 'operation_ads_error';

    protected $guarded = [];

    //public $timestamps = false;

    public static function errorRecord($error): bool
    {
        return self::query()->insert($error);
    }

    public function country(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(SysCountry::class,'country_id');
    }

    /**
     * 类型
     */
    const TYPE_SP = 1; //'Ads'(产品广告)
    const TYPE_BUSINESS = 2; //'Business'(商业广告)
    const TYPE_ST = 3; //'VideoCampaign'(电视广告)
    const TYPE_SB = 4; // 'BrandsCampaign'(品牌广告)
    const TYPE_SD = 5; //'DSP'(展示广告)
    public static $_type = [
        self::TYPE_SP => 'Ads',
        self::TYPE_BUSINESS => 'Business',
        self::TYPE_ST => 'VideoCampaign',
        self::TYPE_SB => 'BrandsCampaign',
        self::TYPE_SD => 'DSP'
    ];

    /**
     * 状态
     */
    const STATUS_NO = 0; //待处理(未处理)
    const STATUS_YES = 1; //已处理
    public static $_status = [
        self::STATUS_NO => '待处理',
        self::STATUS_YES => '已处理',
    ];

    /**
     * 同步状态
     */
    const SYNC_NO = 0; //未同步
    const SYNC_YES = 1; //同步成功
    const SYNC_ERROR = 2; //同步失败
    public static $_sync = [
        self::SYNC_NO => '未同步',
        self::SYNC_YES => '同步成功',
        self::SYNC_ERROR => '同步失败'
    ];
}
